home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1997 August / Walnut Creek CDROM.7z / VOL_400 / 460_01 / UI / SIMPLE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-11  |  5.4 KB  |  190 lines

  1.  
  2. #ifndef _simple_h_
  3. #define _simple_h_
  4.  
  5.  
  6.  
  7.  
  8.  
  9. /*
  10.  *
  11.  *          Copyright (C) 1995, M. A. Sridhar
  12.  *  
  13.  *
  14.  *     This software is Copyright M. A. Sridhar, 1995. You are free
  15.  *     to copy, modify or distribute this software  as you see fit,
  16.  *     and to use  it  for  any  purpose, provided   this copyright
  17.  *     notice and the following   disclaimer are included  with all
  18.  *     copies.
  19.  *
  20.  *                        DISCLAIMER
  21.  *
  22.  *     The author makes no warranties, either expressed or implied,
  23.  *     with respect  to  this  software, its  quality, performance,
  24.  *     merchantability, or fitness for any particular purpose. This
  25.  *     software is distributed  AS IS.  The  user of this  software
  26.  *     assumes all risks  as to its quality  and performance. In no
  27.  *     event shall the author be liable for any direct, indirect or
  28.  *     consequential damages, even if the  author has been  advised
  29.  *     as to the possibility of such damages.
  30.  *
  31.  */
  32.  
  33.  
  34.  
  35.  
  36. //   The SimpleVObject is an abstract class that encapsulates a VisualObject
  37. //   that displays either a
  38. //   single data item or a homogeneous collection of data items.
  39. //
  40. // 
  41. //   SimpleVObject includes in its protocol a data structure called the {\it
  42. //   model\/} 
  43. //   and a selection mechanism determined by a {\it selection}. The actual 
  44. //   interpretation of model and selection and their management is
  45. //   left to subclasses of the SimpleVObject. The model is not owned by
  46. //   this object but 
  47. //   passed to it at construction by the derived class. The simple object
  48. //   may however modify the
  49. //   model. The parent of a simple object must be a VObjCollection.
  50. // 
  51. // 
  52. //   The model has this object as a dependent and invokes
  53. //   {\tt _ModelChanged()} when it changes.
  54. //
  55. // An application only  needs to instantiate classes derived from
  56. // SimpleVObject, never a SimpleVObject itself. So all SimpleVObject
  57. // constructors are protected.
  58.  
  59.  
  60. #if defined(__GNUC__)
  61. #pragma interface
  62. #endif
  63.  
  64.  
  65. #include "ui/visualob.h"
  66.  
  67.  
  68. #if defined(__OS2__) && defined(__IBMCPP__)
  69. MRESULT EXPENTRY CallBackSubclassProc (HWND hWnd, ULONG msg,
  70.                                        MPARAM p1, MPARAM p2);
  71. #endif
  72.  
  73. class YACL_UI UI_VObjCollection;
  74.  
  75. class YACL_UI UI_SimpleVObject: public UI_VisualObject {
  76.  
  77. public:
  78.  
  79.     virtual UI_WindowClass WindowClass () const = 0;
  80.     // Override the inherited method.
  81.     
  82.     const char* ClassName() const {return "UI_SimpleVObject";};
  83.  
  84.     
  85. protected:
  86.  
  87.     UI_SimpleVObject (UI_VisualObject* parent, const UI_Rectangle& r,
  88.                       UI_ViewID id = -1, long style = -1);
  89.     // Constructor: create a SimpleVObject as child of {\tt parent}, with
  90.     // given shape and id. The SimpleVObject owns its model.
  91.  
  92.     UI_SimpleVObject (UI_VisualObject* parent, CL_Object* model,
  93.                       UI_ViewID id, const UI_Rectangle& r,
  94.                       long style = -1);
  95.     // Constructor: create a SimpleVObject as child of {\tt parent}, with
  96.     // given shape and id. The SimpleVObject does not own its model, but
  97.     // borrows the parameter {\tt model} from its caller to use as model.
  98.  
  99.  
  100. #if defined(__MS_WINDOWS__) || defined(__MS_WIN32__)
  101.     UI_SimpleVObject (UI_VObjCollection* parent, UI_ViewID id, UI_ViewHandle h);
  102.     // [MS-Windows-specific] For resource-based construction.
  103.  
  104. #endif
  105.                      
  106.  
  107.     ~UI_SimpleVObject(); 
  108.  
  109.     virtual bool _ModelChanged ();
  110.     // Called by our model when it changes. The default
  111.     // implementation calls {\tt Paint}.
  112.  
  113.     bool MakeVisualElement ();
  114.     // Override the inherited method. The implementation supports the 3-d
  115.     // look under MS-Windows.
  116.  
  117.     bool DestroyVisualElement ();
  118.     // Destroy the visual element. This overrides the inherited method.
  119.  
  120.     void _PrivateInitialize();
  121.     // Override the inherited method. Perform miscellaneous initializations.
  122.  
  123.  
  124.     friend class YACL_UI UI_Controller;
  125.  
  126. #if defined(__X_MOTIF__)
  127.     bool _ShapeRectChanged ();
  128.     // [X-Motif-specific, for internal use only] Override the inherited
  129.     // method.
  130.  
  131. #endif
  132.  
  133. public:
  134.  
  135.     // ------------- For YACL internal use only --------------
  136.  
  137.     bool SetStyleParam();
  138.     // [MS-Windows-specific, for YACL internal use only]
  139.     
  140. protected:
  141.  
  142.     // Instance variables:
  143.     
  144.     bool       _ownModel;
  145.  
  146. #if defined(__OS2__)
  147.  
  148. private:
  149.     void _Subclass ();
  150.     // [OS/2-specific, for YACL internal use only] Subclass the control of
  151.     // this SimpleVObject.
  152.  
  153.     PFNWP _oldProc;
  154.  
  155. #if defined(__IBMCPP__) // IBMCPP only allows _OptLink calling convention
  156.                         // for member functions.  the work around is to
  157.                         // make a global function that is used to call the
  158.                         // class static function...
  159.     static MRESULT SubclassProc (HWND hWnd, ULONG msg,
  160.                                  MPARAM p1, MPARAM p2);
  161.     // [OS/2- and IBM C++-specific, for YACL internal use only]
  162.  
  163.     friend MRESULT EXPENTRY CallBackSubclassProc(HWND hWnd, ULONG msg,
  164.                                                  MPARAM p1, MPARAM p2);
  165.     // [OS/2- and IBM C++-specific, for YACL internal use only] 
  166.  
  167. #else
  168.     static MRESULT EXPENTRY SubclassProc (HWND hWnd, ULONG msg,
  169.                                           MPARAM p1, MPARAM p2);
  170.     // [OS/2-specific, for YACL internal use only] The window procedure used
  171.     // for subclassing.
  172.  
  173. #endif
  174.     virtual void WindowProcHook (HWND hWnd, ULONG msg, MPARAM p1, MPARAM p2);
  175.     // [OS/2-specific, for YACL internal use only] Called by the
  176.     // subclassing procedure.
  177.     
  178. #endif
  179. };
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188. #endif
  189.  
  190.